﻿// ===============================================================================
// IBaseDao.cs
// EOS Framework
// ===============================================================================
// Copyright (c) EOS Development Group. All rights reserved.
// ===============================================================================

namespace EOS.Framework.Data
{
    using System.Collections.Generic;

    /// <summary>
    /// This is just a marker interface to find all dao classes.
    /// </summary>
    public interface IBaseDao
    {
    }

    public interface IBaseDao<T> : IBaseDao
    {
        /// <summary>
        /// Gets the specified id.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        T Get(int id);

        /// <summary>
        /// Finds all.
        /// </summary>
        /// <returns></returns>
        IList<T> FindAll();

        IList<T> Find(int firstResult, int limit);


        /// <summary>
        /// Count all entries.
        /// </summary>
        /// <returns>Number of entries.</returns>
        int Count();

        /// <summary>
        /// Saves the or update.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void SaveOrUpdate(T entity);

        /// <summary>
        /// Saves the or update.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void SaveOrUpdate(T entity, bool commit);

        /// <summary>
        /// Deletes the specified entity.
        /// </summary>
        /// <param name="entity">The entity.</param>
        void Delete(T entity);
    }
}
